/*
 * @Description: 生态沟渠
 */
import zhreq from "@/api/axios";
export default {
  /**
   * @description: 获取列表 *代表必填
   * @param {String/Number} page *
   * @param {String/Number} size *
   * @param {Object} entity {componyId: 1} *
   * @param {String} order 排序方式 ASC DESC 默认ASC
   * @param {String} sort 自定义排序方式 'createTime'
   * @return {Array}
   */
  getList(params) {
    let searchparams = {
      page: params.page,
      size: params.size,
      sort: "timestamp",
      entity: {
        "farmingTypeNo": sessionStorage.getItem('farmingTypeNo'),
        "ditchName": params.ditchName
      }
    }
    searchparams.entity.organizationNo = sessionStorage.getItem('parentId')
    return zhreq.post("/ditch/queryPageList", searchparams);
  },

  /**
   * @description:条件查询
   * @param null *
   * @return {Object}
   */
  getditchByCondition(params) {
    return zhreq.post("/ditch/queryByCondition", {
      ...params,
      "farmingTypeNo": sessionStorage.getItem('farmingTypeNo')
    });
  },
  /**
   * @description: 新增
   * @param {Object} formData *
   * @return {Object}
   */
  addlist(formData) {
    return zhreq.post("/ditch/add", {
      ...formData,
      "farmingTypeNo": sessionStorage.getItem('farmingTypeNo'),
      "organizationNo": sessionStorage.getItem('organizationNo')
    });
  },
  /**
   * @description: 编辑
   * @param {Object} formData *
   * @return {Object}
   */
  editlist(formData) {
    return zhreq.post("/ditch/edit", formData);
  },
  /**
   * @description: 批量删除
   * @param {String} plantingUnit *
   * @return {Array}
   */
  dellist(idlist) {
    return zhreq.post(`/ditch/delList`, {
      'ditchIdList': idlist
    });
  }
};
